package jmine.tec.proxy.cglib;

import java.lang.reflect.Method;

import jmine.tec.proxy.chain.ChainElement;
import net.sf.cglib.proxy.MethodProxy;

/**
 * Fast version of {@link CGLIBInvocationChain} that uses faster
 * {@link MethodProxy#invokeSuper(Object, Object[])}
 * 
 * @author takeshi
 * 
 */
public class FastCGLIBInvocationChain extends CGLIBInvocationChain {

    /**
     * C'tor
     * 
     * @param delegate
     *            the deleagate object
     * @param el
     *            the ChainElements
     * @param method
     *            the {@link Method}
     * @param proxy
     *            the proxy objecton witch the method was originally invoked
     * @param args
     *            the arguments
     * @param methodProxy
     *            the {@link MethodProxy} from cglib
     */
    public FastCGLIBInvocationChain(final Object delegate, final ChainElement[] el,
            final Method method, final Object proxy, final Object[] args,
            final MethodProxy methodProxy) {
        super(delegate, el, method, proxy, args, methodProxy);
    }

    /**
     * @return Object
     * @throws Throwable
     *             e
     * @see br.com.maps.util.proxy.cglib.CGLIBInvocationChain#invokeEndOfChain()
     */
    @Override
    protected Object invokeEndOfChain() throws Throwable {
        return this.getFastMethod().invokeSuper(this.getBean(), this.getParams());
    }

}
